package com.cjs.example.stock.dubbo;

import com.cjs.example.common.dto.CommodityDTO;
import com.cjs.example.common.dubbo.StockDubboService;
import com.cjs.example.common.response.ObjectResponse;
import com.cjs.example.stock.service.StockService;
import io.seata.core.context.RootContext;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@Slf4j
@DubboService
public class StockDubboServiceImpl implements StockDubboService {

    @Autowired
    private StockService stockService;

    @Override
    public ObjectResponse decreaseStock(CommodityDTO commodityDTO) {
        log.info("全局事务ID: {}", RootContext.getXID());
        return stockService.decreaseStock(commodityDTO);
    }
}
